<?php

/**
 * BaseTag base model
 *
 * PHP version 5
 *
 * @category   Web
 * @package    Data2People
 * @subpackage Models
 * @author     Mike Bevz <mike.bevz@data2people>
 * @copyright  2007-2008 (c) Mike Bevz
 * @license    The BSD License http://data2people.com/license.txt
 * @version    SVN: $Id: BaseTag.php 14 2008-12-01 23:02:54Z michael.bevz $
 *
 *
 */
/**
 * Includes
 */
require_once 'Doctrine/Record.php';
require_once 'TimestampListener.php';

/**
 * BaseTag base model class
 *
 * PHP version 5
 *
 * @category   Web
 * @package    Data2People
 * @subpackage Models
 * @author     Mike Bevz <mike.bevz@data2people>
 * @copyright  2007-2008 (c) Mike Bevz
 * @license    The BSD License http://data2people.com/license.txt
 * @version    SVN: $Id: BaseTag.php 14 2008-12-01 23:02:54Z michael.bevz $
 *
 *
 */
abstract class BaseTag extends Doctrine_Record
{
    /**
    * Sets table definitions
    *
    * @return void
    */
    public function setTableDefinition()
    {
        $this->setTableName('tags');
        $this->hasColumn('id', 'integer', 4, array('primary' => true,
                                                   'autoincrement' => true,
                                                   'unsigned' => true));
        $this->hasColumn('content', 'string', 255, array('unique' => true,
                                                         'notblank' => true));
        
        $this->option('type', 'INNODB');
        $this->option('collate', 'utf8_unicode_ci');
        $this->option('charset', 'utf8');
        
    }
    
   /**
    * Sets up relations
    *
    * @return void
    */
    public function setUp()
    {
        $this->hasMany('News', array('local' => 'tag_id',
                                     'foreign' => 'news_id',
                                     'refClass' => 'TagRefNews'
                                     ));

         
        $this->actAs('Timestampable',
               array('created_at' =>  array('name'  =>  'created_at',
                                            'type'    =>  'timestamp',
                                            'format'  =>  'Y-m-d H:i:s',
                                            'disabled' => false,
                                            'options' =>  array()),
                     'updated_at' =>  array('name'  =>  'updated_at',
                                            'type'    =>  'timestamp',
                                            'format'  =>  'Y-m-d H:i:s',
                                            'disabled' => false,
                                            'options' =>  array())));
        
       
        $this->setListener(new TimestampListener());
    }
}